package org.wordml.core.util;

import java.io.IOException;
import java.io.OutputStream;

/**
 * OutputStream implementation backed by a StringBuilder
 * @author juan.c.garciamatos
 *
 */
public class StringOutputStream extends OutputStream{
	StringBuilder buffer;
	public StringOutputStream() {
		buffer = new StringBuilder();
	}
	public StringOutputStream(int n) {
		buffer = new StringBuilder(n);
	}
	@Override
	public void write(int b) throws IOException {
		buffer.append((char)b);
	}
	@Override
	public String toString() {
		return buffer.toString();
	}
	public int length(){
		return buffer.length();
	}
	public void setLenght(int l){
		buffer.setLength(l);
	}
	public void clear(){
		buffer.setLength(0);
	}
}
